<!DOCTYPE HTML>
<html>
<head>
    <title>发帖 - Quarkus先锋论坛</title>
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/bootstrap/css/bootstrap-theme.min.css">
    <link rel="stylesheet" href="/bootstrap/css/community.css">
    <link rel="icon" href="/images/logo.png" type="image/x-icon"/>
    <script src="/js/jquery-3.5.1.min.js"></script>
    <script src="/js/jquery.cookie.js"></script>
    <script src="/bootstrap/js/bootstrap.min.js" type="application/javascript"></script>
    <script src="/js/community.js" type="application/javascript"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="google-site-verification" content="QGf2OqDw91EjWtNE07HoLJi0x0G2rIYylk6jn6JEoEQ" />
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-89103576-8"></script>
    <script type="text/javascript" src="/js/bbs.js"></script>
    
    <link rel="stylesheet" href="/editor.md/css/editormd.min.css">
    <link rel="stylesheet" href="/editor.md/css/editormd.preview.min.css">
    <script src="/editor.md/editormd.min.js" type="application/javascript"></script>
    <script src="/editor.md/moment.js" type="application/javascript"></script>
    <script src="/editor.md/lib/marked.min.js"></script>
    <script src="/editor.md/lib/prettify.min.js"></script>
</head>
<script type="application/javascript">
    window.onload = function () {
    	var weir_token = $("#weir-token").val();
    	// console.log("----------weir-token--------" + weir_token)
    	if(weir_token == undefined || weir_token.length == 0){
    		weir_token = window.localStorage.getItem("quarkus-bbs-token");
    	}else{
    		window.localStorage.setItem("quarkus-bbs-token", weir_token);
    		$.cookie('weir-cookie-toekn', weir_token, { expires: 360 });
    	}
    	var weir_token_user = $("#weir-token-user").val();
    	// console.log("----------weir-token-user--------" + weir_token_user)
    	if(weir_token_user == undefined || weir_token_user.length == 0){
    		weir_token_user = window.localStorage.getItem("weir-token-user");
    	}else{
    		window.localStorage.setItem("weir-token-user", weir_token_user);
    	}
        /* var closable = window.localStorage.getItem("closable");
        if (closable == "true") {
            window.close();
            window.localStorage.removeItem("closable");
        } */
    }
</script>
<body>
<input type="hidden" id="weir-token" value="{bbsVo.token}">
{#if bbsVo.user??}
<input type="hidden" id="weir-token-user" value="{bbsVo.user.userName}">
{/if}
<div>
    <nav class="navbar navbar-default">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                        data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Quarkus先锋论坛</span>
                </button>
                <a class="navbar-brand" href="/bbs">Quarkus先锋论坛</a>
            </div>

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <form class="navbar-form navbar-left" action="/" method="get">
                    <div class="form-group">
                        <input type="text" class="form-control" name="search" placeholder="搜索问题">
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>
                <ul class="nav navbar-nav">
                    <script>
                        function clickNav(label) {
                            gtag('event', 'click', {
                                'event_category': 'LINK',
                                'event_label': label,
                                'transport_type': 'NAV'
                            })
                        }
                    </script>
                    <li each="ad : ">
                        <a href="ad.url" text="ad.title" onclick="clickNav([[ad.title}]])"
                           target="_blank"></a>
                    </li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    {#if bbsVo.user??}
                    <li>
                        <a href="/publish">发帖</a>
                    </li>
                    <li><a href="/profile/replies">通知 <span class="badge" text="session.unreadCount"></span></a>
                    </li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                           aria-expanded="false">
                            <span>{bbsVo.user.userName}</span>
                            <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a href="/profile/questions">我的问题</a></li>
                            <li><a href="/logout">退出登录</a></li>
                        </ul>
                    </li>
                    {#else}
                    <li>
                        <a href="#" data-toggle="modal" data-target="#myModal">登录</a>
                    </li>
                    {/if}

                </ul>
            </div>
        </div>
    </nav>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document" style="margin-top: 200px;wid 300px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">登录注册</h4>
                </div>
                <div class="modal-body" style="text-align:center">
                    <a href="https://gitee.com/oauth/authorize(client_id='e542c33bb680ea612ce21b8efb397274eae34833553bc80bc9ff881425d1b883',redirect_uri=,response_type=code)">
                        <img src="/images/gitee.png">
                    </a>
                    <a href="https://github.com/login/oauth/authorize?client_id=f2bb003d1642d62b8cf5&redirect_uri=http://fe80-223-91-168-24.ngrok.io/oauth-github/callback&scope=user&state=weir">
                        <img src="/images/github.png">
                    </a>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="container-fluid main">
    <div class="row">
        <div class="col-lg-10 col-md-12 col-sm-12 col-xs-12">
            <h2><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 发起</h2>
            <hr>

            <form id="post_form" action="/posts_bbs/add" method="post">
                <input type="hidden" id="post_id" name="id" value="{bbsVo.bbsPost.id ?: ''}">
                <div class="form-group">
                    <label for="title">标题:</label>
                    <input type="text" class="form-control" value="{bbsVo.bbsPost.title ?: ''}" id="title" name="title"
                           placeholder="标题……"
                           autocomplete="off">
                </div>
                <div class="form-group" id="question-editor" style="z-index: 2">
                    <label for="description">补充 (必填，请参照右侧提示):</label>
                    <textarea name="content" id="description" text="{bbsVo.bbsPost.content ?: ''}" style="display:none;"
                              class="form-control"
                              cols="30"
                              rows="10"></textarea>
                </div>
                <script type="text/javascript">
                    $(function () {
                        var editor = editormd("question-editor", {
                            width: "100%",
                            height: 350,
                            path: "/editor.md/lib/",
                            delay: 0,
                            watch: true,
                            placeholder: "开始你的文章吧。。。。",
                            imageUpload: true,
                            imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
                            imageUploadURL: "/kindeditor/file-upload-bbs/" + $("#post_id").val(),
                        });
                    });
                </script>
               <div class="form-group">
                    <label for="tag">添加标签:</label>
                    <input type="text" class="form-control" value="{bbsVo.bbsPost.tag ?: ''}" id="tag" name="tag"
                           autocomplete="off"
                           placeholder="输入标签，以，号分隔">
                </div>

                <div class="container-fluid main ">
                    <div class="row">
                        <div class="col-lg-9 col-md-12 col-sm-12 col-xs-12">
                            <div class="alert alert-danger col-lg-12 col-md-12 col-sm-12 col-xs-12">
                            </div>
                        </div>
                        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12">
                            <button type="button" class="btn btn-success btn-publish " onclick="postAdd()">
                                发布
                            </button>
                        </div>
                    </div>
                </div>

            </form>
            <script type="text/javascript">
                function postAdd(){
                	var fields = $('#post_form').serializeArray();
			        var o = {}; //声明一个对象
			        $.each(fields, function(index, field) {
			            // obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
			            if (o[this.name] !== undefined) {
			                if (!o[this.name].push) {
			                    o[this.name] = [o[this.name]];
			                }
			                if (undefined != this.value && '' != this.value) {
			                    o[this.name].push(this.value);
			                }
			            } else {
			            	if (undefined != this.value && '' != this.value) {
			                   o[this.name] = this.value;
			            	}
			            }
			        });
				  $.ajax({
					    type: "POST",
					    url: "/posts_bbs/add",
					    contentType: "application/json", //必须有
					    dataType: "json", //表示返回值类型，不必须
					    data: JSON.stringify(o),
					    success: function (j) {
					    	window.location.href='/bbs';
					    },
					    error : function(j){
					    	
			            }
					});
                }
				
			</script>
        </div>
        <div class="col-lg-2 col-md-12 col-sm-12 col-xs-12">
            <h3>发帖指南</h3>
            • 标题: 请用精简的语言描述您发布的标题，不超过200字 <br>
            • 内容: 详细描述您的发帖内容，并确保问题描述清晰直观, 并提供一些相关的资料<br>
            • 选择标签: 选择一个或者多个合适的标签，用逗号隔开，每个标签不超过10个字<br>
        </div>
    </div>
</div>
<div class="footer">
    <div>Copyright © 2022  豫ICP备2021013020号-1 · All Rights Reserved Powered By <a href="http://www.loveweir.com" target="_blank"> 爱威尔 </a></div>
</div>
</body>
</html>